#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5+10;
int n;
struct node{
    int d,v,a;
}c[N];
int p[N];
int read()
{
    ll res=0,f=1;
    char ch=getchar();
    while(!isdigit(ch)){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(isdigit(ch)){
        res=res*10+ch-'0';
        ch=getchar();
    }
    return res*f;
}
bool cmp(vector<int> x,vector<int> y)
{
    return x.size()>y.size();
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    while(T--)
    {
        int n,m,l,V;
        cin>>n>>m>>l>>V;
        bool flag1=1,flag2=1;
        for(int i=1;i<=n;i++)
        {
            cin>>c[i].d>>c[i].v>>c[i].a;
            if(c[i].a!=0) flag1=0;
            if(c[i].a>=0) flag2=0;
        }
        for(int i=1;i<=m;i++)
        {
            cin>>p[i];
        }
        sort(p+1,p+m+1);
        if(flag1)
        {
            int cnt=0;
            for(int i=1;i<=n;i++)
            {
                if(c[i].v>V)
                {
                    if(c[i].d<=p[m]) cnt++;
                }
            }
            cout<<cnt<<' ';
            if(cnt!=0) cout<<m-1<<endl;
            else cout<<m<<endl;
        }
        else
        {
            int cnt=0,sum=0;
            vector<int> b[N];
            for(int i=1;i<=n;i++)
            {
                bool fla=1;
                for(int j=1;j<=m;j++)
                {
                    if(p[j]-c[i].d<0) continue;
                    int s=p[j]-c[i].d;
                    if(sqrt(c[i].v*c[i].v+2*c[i].a*s)>V)
                    {
                        if(fla)
                        {
                            sum++;fla=0;
                        }
                        b[j].push_back(i);
                      //  break;
                    }
                }
            }
            sort(b+1,b+n+1,cmp);
            cout<<sum<<' ';
            if(b[1].size()>=sum) cout<<m-1<<endl;
            else cout<<m-2<<endl;
            
        }
    }
    return 0;
}